define(['../../common/common', '../../common/pathCompute'], function($, pathfn) {
	var interface =  pathfn.interface;
  	projectDw = function(projectId){
  		layui.use([ 'table','form','laypage','layedit' ],function() {
          	var table = layui.table,
          	form = layui.form,
          	layedit = layui.layedit,
          	laypage = layui.laypage;
          	init= function(){ 
           	 	projectIofo.tableInit('P_BASE');
            	bindEvents();
          	},       	
          	projectIofo= {
          		tableInitObj: function(){
					var listObj = {
						P_BASE: {
							id: 'projectInfo-base',
			                elem: '#projectInfo-base', //指定原始表格元素选择器（推荐id选择器）
			                height: 'full-140', //容器高度
			                cols:  [[ //标题栏
			                  {field:'no', title: '序号', width:100, sort: true, align:'center'}
			                  ,{field:'name', title: '名称', width:280, sort: true}
			                  ,{field:'value', title: '内容', width:280}
			                ]],
			                url: interface.projectInfo,
			                method: 'get',
			                page: false, //开启分页
			                initSort: {
			                  field: 'name' //排序字段，对应 cols 设定的各字段名
			                  ,type: 'desc' //排序方式  asc: 升序、desc: 降序、null: 默认排序
			                },
			                loading: true
						},
						P_OTHER: {
							id: 'projectInfo-other',
			                elem: '#projectInfo-other', //指定原始表格元素选择器（推荐id选择器）
			                height: 'full-180', //容器高度
			                cols:  [[ //标题栏
			                  {field:'no', title: '序号', width:100, sort: true, align:'center'}
			                  ,{field:'name', title: '名称', width:280, sort: true}
			                  ,{field:'value', title: '内容', width:280}
			                  ,{field:'remark', title: '备注', width:280}
			                  ,{field:'caozuo', fixed: 'right', title: '操作', width:160, align:'center', toolbar: '#barDemo'}
			                ]],
			                url: interface.projectInfo,
			                method: 'get',
			                page: false, //开启分页
			                initSort: {
			                  field: 'name' //排序字段，对应 cols 设定的各字段名
			                  ,type: 'desc' //排序方式  asc: 升序、desc: 降序、null: 默认排序
			                },
			                loading: true
						},
						P_COST: {
							id: 'projectInfo-cost',
			                elem: '#projectInfo-cost', //指定原始表格元素选择器（推荐id选择器）
			                height: 'full-140', //容器高度
			                cols:  [[ //标题栏
			                  {field:'no', title: '序号', width:100, sort: true, align:'center'}
			                  ,{field:'name', title: '名称', width:280, sort: true}
			                  ,{field:'value', title: '内容', width:280}
			                ]],
			                url: interface.projectInfo,
			                method: 'get',
			                page: false, //开启分页
			                initSort: {
			                  field: 'name' //排序字段，对应 cols 设定的各字段名
			                  ,type: 'desc' //排序方式  asc: 升序、desc: 降序、null: 默认排序
			                },
			                loading: true
						}

					}	              			
	              	return listObj;           
	            },
	            tableInit: function(info){
		            var _this = this,
		            defaults = {
		                where: {
		                  projectId: projectId,
		                  type: info
		                },
		                done: function(res, curr, count){
		                }
		            }
		            console.log(_this.tableInitObj()[info])
		            $.extend(true, defaults, _this.tableInitObj()[info]);        
		            table.render(defaults);
		        }
          	},
          	bindEvents= function(){
          		table.on('tool(projectInfoOtherEvent)', function(obj){
	                var dataObj = obj.data,
	                delContent = '确认删除名称为'+dataObj.name+'的一行吗？';
	                if(obj.event === 'del'){
	                	console.log(delContent)
	                  var openObj = {
	                    "content": delContent,
	                    "title":'删除',
	                    "success": function(layero, index){
	                      
	                    },
	                    "yes": function(layero, index){
	                      
	                        layer.close(index);
	                        
	                    }
	                  }
	                  layerOpenfn(openObj);
	                }
	            });
          		$('.projectInfo').each(function(index, el) {
      				var $li = $(this).find('.projectInfo-title').find('li'),
      				$list = $(this).find('.project-content').find('.project-list');
      				$li.each(function(index, el) {          			
          				$(this).click(function(){
          					var info = $(this).data('info');
          					$li.removeClass('active').eq(index).addClass('active');
	          				$list.hide(0).eq(index).show(0);
          					if(info == 'P_CODE'){
          						$.ajaxRequest({
							    	url: interface.projectInfo,
							    	data:{
										projectId: projectId,
		                  				type: info
									},
							    	successfn: function(data) {	
							    		$('#projectInfo-code').html(data.data[0] && data.data[0].codeInfo);
							    		layedit.build('projectInfo-code',{
		          							height:'full-200',
		          							tool: ['strong','italic','underline','del','|' ,'left','center','right','link','unlink','face']
		          						});
							    	}
							    })
          					}else if(info == 'P_COSTER'){

          					}else{	          					
	          					projectIofo.tableInit(info);
          					}
          					
          				})
          			});
      			});
          	};
          	init();
        })
	}
	return projectDw;
})
